var removeDuplicates = function(nums) {
    var j = 0;
    for (var i = 0; i < nums.length; i++) {
        if (!nums.includes(nums[i], i + 1)) {
            nums[j] = nums[i];
            j++;
        }
    }
    return j;
};
nums = [1, 2, 5, 5, 7, 7, 9];

console.log(removeDuplicates(nums));
console.log(nums);